<?php



   extract(shortcode_atts(array(

	  "type" => 'full_width_background',

	  'image_url'=> '', 

	  'bg_pos'=> '', 

	  'bg_repeat' => '', 

	  'parallax_bg' => '', 

	  'background_color'=> '', 

	  'exclude_row_header_color_inherit' => '',

	  'text_align'=> '', 

	  'vertically_center_columns' => '',

	  

	  'video_bg'=> '', 

	  'enable_video_color_overlay'=> '', 

	  'video_overlay_color'=> '', 

	  'video_webm'=> '', 

	  'video_mp4'=> '', 

	  'video_ogv'=> '', 

	  'video_image'=> '', 

	  

	  "top_padding" => "20", 

	  "bottom_padding" => "20",

	  'text_color' => 'dark',  

	  'custom_text_color' => '',  

	  'class' => ''), 

	$atts));

	

	wp_enqueue_style( 'js_composer_front' );

	wp_enqueue_script( 'wpb_composer_front_js' );

	wp_enqueue_style('js_composer_custom_css');

	

    $style = null;

	$etxra_class = null;

	$bg_props = null;

	$using_image_class = null;

	$using_bg_color_class = null;

	$using_custom_text_color = null;

	

	if(!empty($image_url)) {

		

		if(!preg_match('/^\d+$/',$image_url)){

				

			$bg_props .= 'background-image: url('. $image_url . '); ';

			$bg_props .= 'background-position: '. $bg_pos .'; ';

		

		} else {

			$bg_image_src = wp_get_attachment_image_src($image_url, 'full');

			

			$bg_props .= 'background-image: url('. $bg_image_src[0]. '); ';

			$bg_props .= 'background-position: '. $bg_pos .'; ';

		}

		

		//for pattern bgs

		if(strtolower($bg_repeat) == 'repeat'){

			$bg_props .= 'background-repeat: '. strtolower($bg_repeat) .'; ';

			$etxra_class = 'no-cover';

		} else {

			$bg_props .= 'background-repeat: '. strtolower($bg_repeat) .'; ';

			$etxra_class = null;

		}



		$using_image_class = 'using-image';

	}

	

	if(!empty($background_color)) {

		$bg_props .= 'background-color: '. $background_color.'; ';

		if($exclude_row_header_color_inherit != 'true') $using_bg_color_class = 'using-bg-color';

	}

	

	if(strtolower($parallax_bg) == 'true'){

		$parallax_class = 'parallax_section';

	} else {

		$parallax_class = 'standard_section';

	}

	

	if(strtolower($vertically_center_columns) == 'true'){

		$vertically_center_class = 'vertically-align-columns';

	} else {

		$vertically_center_class = null;

	}

	

	$style .= 'padding-top: '. $top_padding .'px; ';

	$style .= 'padding-bottom: '. $bottom_padding .'px; ';

	

	if(!empty($custom_text_color)) {

		$style .= 'color: '. $custom_text_color .'; ';

		$using_custom_text_color = 'data-using-ctc="true"';

	}

	

	//main class

	if($type == 'in_container') {

		

		$main_class = "";

		

	} else if($type == 'full_width_background'){

		

		$main_class = "full-width-section ";

		

	} else if($type == 'full_width_content'){

		

		$main_class = "full-width-content ";

	}

	 

    echo'<div id="'.uniqid("fws_").'" class="wpb_row vc_row-fluid '. $main_class . $parallax_class . ' ' . $vertically_center_class . ' ' . $class . ' " '.$using_custom_text_color.' style="'.$style.'">';

	

	//row bg 

	echo '<div class="row-bg-wrap"> <div class="row-bg '.$using_image_class . ' ' . $using_bg_color_class . ' '. $etxra_class.'" style="'.$bg_props.'"></div> </div>';

	

	//video bg

	if($video_bg) {

		

		if ( floatval(get_bloginfo('version')) >= "3.6" ) {

			wp_enqueue_script('wp-mediaelement');

			wp_enqueue_style('wp-mediaelement');

		} else {

			//register media element for WordPress 3.5

			wp_register_script('wp-mediaelement', get_template_directory_uri() . '/js/mediaelement-and-player.min.js', array('jquery'), '1.0', TRUE);

			wp_register_style('wp-mediaelement', get_template_directory_uri() . '/css/mediaelementplayer.min.css');

			

			wp_enqueue_script('wp-mediaelement');

			wp_enqueue_style('wp-mediaelement');

		}

		

		//parse video image

		if(strpos($video_image, "http://") !== false){

			$video_image_src = $video_image;

		} else {

			$video_image_src = wp_get_attachment_image_src($video_image, 'full');

			$video_image_src = $video_image_src[0];

		}

		

		$poster_markup = (!empty($video_image)) ? 'poster="'.$video_image_src.'"' : null ;



		if($enable_video_color_overlay != 'true') $video_overlay_color = null;

		$video_markup .=  '<div class="video-color-overlay" data-color="'.$video_overlay_color.'"></div>';

		

			 

		$video_markup .= '

		

		<div class="mobile-video-image" style="background-image: url('.$video_image_src.')"></div>

		<div class="nectar-video-wrap">

			

			

			<video class="nectar-video-bg" width="1800" height="700" '.$poster_markup.' controls="controls" preload="auto" loop autoplay>';

	

			    if(!empty($video_webm)) { $video_markup .= '<source type="video/webm" src="'.$video_webm.'">'; }

			    if(!empty($video_mp4)) { $video_markup .= '<source type="video/mp4" src="'.$video_mp4.'">'; }

			    if(!empty($video_ogv)) { $video_markup .= '<source type="video/ogg" src="'. $video_ogv.'">'; }

			  

			$video_markup .='</video>

	

		</div>';

		

		echo $video_markup;

	}





    echo '<div class="col span_12 '.strtolower($text_color).' ' .$text_align.'">'.do_shortcode($content).'</div></div>';

	

?>